package com.station.administrators.service.impl;

import com.station.administrators.dao.NavigationDao;
import com.open.capacity.common.model.NavigationModel;
import com.station.administrators.service.NavigationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author YangGang
 * @Title:
 * @Description: TODO
 * @date 2021/6/29/11:06
 */
@Service
public class NavigationServiceImpl implements NavigationService {
    @Autowired
    private NavigationDao navigationDao;

    @Override
    public void add(NavigationModel navigation) {
        if(navigation.getNaviid()!=null){
            navigationDao.update(navigation);
        }else {
            navigationDao.add(navigation);
        }

    }

    @Override
    public void update(NavigationModel navigation) {
        navigationDao.update(navigation);
    }

    @Override
    public void delete(Long id) {
        navigationDao.delete(id);
    }

    @Override
    public NavigationModel findById(Long id) {
        return  navigationDao.findById(id);
    }

    @Override
    public List<NavigationModel> findAll(NavigationModel navigation) {
        Integer page = navigation.getPage();
        Integer limit = navigation.getLimit();
        Integer page1=(page-1)*limit;
        navigation.setPage(page1);
        return  navigationDao.findAll(navigation);
    }

    @Override
    public Integer getCount(NavigationModel navigation) {
        return  navigationDao.getCount(navigation);
    }
}
